var pageii = null;
var grid = null;
$(function() {	
	grid = lyGrid({
		pagId : 'paging',
		l_column : [ {
			colkey : "id",
			name : "id"
		},{
			colkey : "judgePeople",
			name : "评审参与人员"
		},{
			colkey : "departmentId",
			name : "申请部门"
		},{
			colkey : "equipmentSpecification",
			name : "设备名称"
		}, {
			colkey : "equipmentName",
			name : "设备规格"
		},{
			colkey : "equipmentModel",
			name : "设备型号"
		},{
			colkey : "equipmentCount",
			name : "设备数量"
		},{
			colkey : "reason",
			name : "购买原因"
		},{
			colkey : "price",
			name : "报价"
		},{
			colkey : "departmentJudge",
			name : "部门审批"
		},{
			colkey : "judgeContent",
			name : "评审内容"
		},{
			colkey : "judgeResult",
			name : "评审结果"
		},{
			colkey : "managerJudge",
			name : "总经理审批"
		},{
			colkey : "remark",
			name : "备注"
		},{
			colkey : "status",
			name : "状态"
		},{
			colkey : "pricePic",
			name : "报价单图片"
		}, {
			colkey : "acceptanceStatus",
			name : "验收状态"
		},{
			colkey : "date",
			name : "日期",
			renderData : function(rowindex,data, rowdata, column) {
				return new Date(data).format("yyyy-MM-dd hh:mm:ss");
			}
		},{
			colkey : "operation",
			name : "操作", 
			
		}],
		jsonUrl : rootPath + '/equip/equip_findByPage.shtml',
		dymCol:true,
		checkbox : true,
		serNumber : false
	});
	
	$("#addFun").click("click", function() {
		addAccount();
	});
	$("#editFun").click("click", function() {
		editAccount();
	});
	$("#delFun").click("click", function() {
		delAccount();
	});
	$("#acceptFun").click("click", function() {
		acceptAccount();
	});
	$("#search").click("click", function() {// 绑定查询按扭
		
		var searchParams = $("#searchForm").serializeJson();
		grid.setOptions({
			data : searchParams
		});
	});		
});
function editAccount() {
	var cbox = grid.getSelectedCheckbox();
	if (cbox.length > 1 || cbox == "") {
		layer.msg("只能选中一个");
		return;
	}
	pageii = layer.open({
		title : "编辑订单",
		type : 2,
		area : [ "800px", "100%" ],
		content : rootPath + '/equip/equip_edit.shtml?id=' + cbox
	});
}
function addAccount() {
	pageii = layer.open({
		title : "新增订单",
		type : 2,
		area : [ "800px", "100%" ],
		content : rootPath + '/equip/equip_adds.shtml'
	});
}
function delAccount() {
	var cbox = grid.getSelectedCheckbox();
	if (cbox == "") {
		layer.msg("请选择删除项！！");
		return;
	}
	layer.confirm('是否删除？', function(index) {
		var url = rootPath + '/equip/equip_deleteEntity.shtml';
		var s = CommnUtil.ajax(url, {
			ids : cbox.join(",")
		}, "json");
		if (s == "success") {
			layer.msg('删除成功');
			grid.loadData();
			
		} else {
			layer.msg('删除失败');
		}
	});
	
}

function acceptAccount() {
	var cbox = grid.getSelectedCheckbox();
	if (cbox == "") {
		layer.msg("请选择验证项！！");
		return;
	}
	layer.confirm('是否验证？', function(index) {
		var url = rootPath + '/equip/equip_accepEntity.shtml';
		var s = CommnUtil.ajax(url, {
			ids : cbox.join(",")
		}, "json");
		if (s == "success") {
			layer.msg('验证成功');
			grid.loadData();
			
		} else {
			layer.msg('验证失败');
		}
	});
	
}



